import cv2

img = cv2.imread('img/example.png', 0)
rows, cols = img.shape[0: 2]
M = cv2.getRotationMatrix2D((cols/2, rows/2), 60, 1)
print(M)
# 仿射变换。 dest(x,y) = src[m11*x+m12*y+m13, m21*x+m22*y+m23]
result = cv2.warpAffine(img, M, (cols, rows))
cv2.imshow('', result)
cv2.waitKey(0)